package com.zhoumin.demo.commons;

import java.util.Date;

//分页查询
public class PageParams {

    private int page;

    private int count;

    //    摄像头位置
    private String cameraAddress;

    //    年月日
    private String year;

    private String month;

    private String day;

    private Date time;

    // 给pageable赋值
    public Pageable get() {

        int offset = (getPage() - 1) * getCount();
        Pageable pageable = new Pageable();
        pageable.setOffset(offset);
        pageable.setCount(getCount());
        return pageable;
    }

    //    给page设置默认值
    public int getPage() {
        return page <= 0 ? 1 : page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    //    给count设置默认值
    public int getCount() {
        return count <= 0 ? 10 : count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getMonth() {
        return month;
    }

    public void setMonth(String month) {
        this.month = month;
    }

    public String getCameraAddress() {
        return cameraAddress;
    }

    public void setCameraAddress(String cameraAddress) {
        this.cameraAddress = cameraAddress;
    }

    public String getDay() {
        return day;
    }

    public void setDay(String day) {
        this.day = day;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    @Override
    public String toString() {
        return "PageParams{" +
                "page=" + page +
                ", count=" + count +
                ", cameraAddress='" + cameraAddress + '\'' +
                ", year='" + year + '\'' +
                ", month='" + month + '\'' +
                ", day='" + day + '\'' +
                ", time=" + time +
                '}';
    }
}
